﻿@model LogManager.ViewModels.StatisticIndexViewModel

@{
    ViewBag.Title = "Statistics";
}

<h2>Index</h2>

<div id="filter-form" class="group">
    @using (Html.BeginForm())
    {
        @Html.DisplayFor(m => m.Filter)
        
        <fieldset style="width:210px;">
            <legend><h3>Report</h3></legend>
            <div class="editor-label">
                @Html.LabelFor(m => m.Reports)
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(m => m.Reports, new SelectList(Model.Reports))
            </div>
        </fieldset>
        <br clear="all" />
        <div>
            <input id="showReport" type="submit" value="View Report" />
        </div>            
    }
</div>

<fieldset>
    <legend><h3>Chart</h3></legend>
    <div id="chart" style="min-width: 800px; min-height: 600px;">
    </div>
</fieldset>

@section Foot{
    <script src="@Url.Content("~/Scripts/highcharts.js")" type="text/javascript" ></script>
    <script type="text/javascript">
        $(function () {
            $('#showReport').click(function (e) {
                e.preventDefault();
                var startDate = $('#Filter_Start').val();
                var endDate = $('#Filter_End').val();
                var reportName = $('#Reports').val();
                $.post('Statistic/'+reportName, {start : startDate, end : endDate}, function(data) {
                    $('#chart').replaceWith(data);
                });
            });
        });   
    </script>
}

